package com.cacho.s2b.lesson.vo;

import com.cacho.s2b.lesson.security.EncryptHelper;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description 测试数据库连接信息，直接配置文件config.ini获取
 * @Author LingWei
 * @date 2023/12/31
 **/

@Getter
@Setter
@Slf4j
public class DBConnectionInfo {
    private String jdbc; //
    private String username; // 数据库登录用户
    private String password; // 数据库登录密码
    // 针对已经加密的密码
    public String getPassword(String key) throws Exception{
        log.info("密码被加密了，需要传入key：{}解密",key);
        try{
            return EncryptHelper.AesCbcDecrypt(password,key);
        }catch(Exception e){
            throw new Exception(String.format("Decode<%s> with key <%s> error:%s",password,key,e.getMessage()));
        }
    }
}
